{include file='public/header' /}
    <script type="text/javascript" src="__PUBLIC__/assets/data.js"></script>
    <script type="text/javascript" src="__PUBLIC__/assets/province.js"></script>
    <style>
        .layui-form-label{width: 140px}
        .layui-input-inline{}
        .header span{background: #009688;margin-left: 30px;padding: 10px;color:#ffffff;}
        .header div{border-bottom: solid 2px #009688;margin: 8px 0 6px 0;}
        .header button{float: right;margin-top: -5px;}
    </style>
</head>
<body style="padding: 10px;">
<div class="header">
    <span>添加房源</span>
    <div></div>
</div>
<form class="layui-form" lay-filter="form">
    <div class="layui-form-item">
        <label class="layui-form-label"><span style="color: #FF5722">*</span>选择业务员</label>
        <div class="layui-input-inline">
            <select name="sales_id" lay-filter="sales_id" value="" lay-verify="required" lay-search>
                <option value="">请选择</option>
                {$data['sales']|raw}
            </select>
        </div>
    </div>

<!--    <div class="layui-form-item">-->
<!--        <label class="layui-form-label"><span style="color: #FF5722">*</span>选择业主</label>-->
<!--        <div class="layui-input-inline">-->
<!--            <select name="sales_id" lay-filter="sales_id" value="" lay-verify="required" lay-search>-->
<!--                <option value="">请选择</option>-->
<!--                {$data['owner']|raw}-->
<!--            </select>-->
<!--        </div>-->
<!--        <div class="layui-form-mid layui-word-aux">如果没有找到请先添加业主</div>-->
<!--    </div>-->


    <div class="layui-form-item">
        <label class="layui-form-label">房屋性质</label>
        <div class="layui-input-inline">
            <select name="con_house_nature" lay-filter="con_house_nature" value="" lay-verify="required">
                <option value="">请选择</option>
                <option value="1">商品房</option>
                <option value="2">房改房</option>
                <option value="3">集资房</option>
                <option value="4">经济适用房</option>
                <option value="5">廉租房</option>
                <option value="6">公租房</option>
                <option value="7">安置房</option>
                <option value="8">小产权房</option>
            </select>
        </div>
    </div>


    <div class="layui-form-item">
        <label class="layui-form-label">产权证书</label>
        <div class="layui-input-inline">
            <select name="con_house_cqzslb" lay-filter="con_house_cqzslb" value="" lay-verify="required">
                <option value="">请选择</option>
                <option value="1">不动产权证书</option>
                <option value="2">房产证</option>
                <option value="3">购房合同</option>
                <option value="4">其他证明</option>
            </select>
        </div>
    </div>


    <div class="layui-form-item">
        <label class="layui-form-label"><span style="color: #FF5722">*</span>产权证书编号:</label>
        <div class="layui-input-inline">
            <input type="text" class="layui-input" name="con_house_zsbh" lay-verify="required">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label"><span style="color: #FF5722">*</span>产权地址:</label>
        <div class="layui-input-inline">
            <input type="text" class="layui-input" name="con_house_cqdz" lay-verify="required">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label"><span style="color: #FF5722">*</span>建筑面积:</label>
        <div class="layui-input-inline">
            <input type="text" class="layui-input" name="con_house_jzmj" lay-verify="required">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">居室数量  室</label>
        <div class="layui-input-inline">
            <select name="con_house_jssl_s" lay-filter="con_house_jssl_s" value=""  lay-verify="required">
                <option value="">请选择</option>
                <option value="1">1</option>
                <option value="2">2</option>
                <option value="3">3</option>
                <option value="4">4</option>
                <option value="5">5</option>
                <option value="6">6</option>
                <option value="7">7</option>
                <option value="8">8</option>
            </select>
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">居室数量  厅</label>
        <div class="layui-input-inline">
            <select name="con_house_jssl_t" lay-filter="con_house_jssl_t" value=""  lay-verify="required">
                <option value="">请选择</option>
                <option value="1">1</option>
                <option value="2">2</option>
                <option value="3">3</option>
                <option value="4">4</option>
                <option value="5">5</option>
                <option value="6">6</option>
                <option value="7">7</option>
                <option value="8">8</option>
            </select>
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">居室数量  厨</label>
        <div class="layui-input-inline">
            <select name="con_house_jssl_c" lay-filter="con_house_jssl_c" value=""  lay-verify="required">
                <option value="">请选择</option>
                <option value="1">1</option>
                <option value="2">2</option>
                <option value="3">3</option>
                <option value="4">4</option>
                <option value="5">5</option>
                <option value="6">6</option>
                <option value="7">7</option>
                <option value="8">8</option>
            </select>
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">居室数量  卫</label>
        <div class="layui-input-inline">
            <select name="con_house_jssl_w" lay-filter="con_house_jssl_w" value=""  lay-verify="required">
                <option value="">请选择</option>
                <option value="1">1</option>
                <option value="2">2</option>
                <option value="3">3</option>
                <option value="4">4</option>
                <option value="5">5</option>
                <option value="6">6</option>
                <option value="7">7</option>
                <option value="8">8</option>
            </select>
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">租户人数上限</label>
        <div class="layui-input-inline">
            <select name="con_house_zhrssx" lay-filter="con_house_zhrssx" value=""  lay-verify="required">
                <option value="">请选择</option>
                <option value="1">1</option>
                <option value="2">2</option>
                <option value="3">3</option>
                <option value="4">4</option>
                <option value="5">5</option>
                <option value="6">6</option>
                <option value="7">7</option>
                <option value="8">8</option>
                <option value="9">9</option>
                <option value="10">10</option>
                <option value="11">11</option>
                <option value="12">12</option>
                <option value="13">13</option>
                <option value="14">14</option>
            </select>
        </div>
    </div>


    <div class="layui-form-item">
        <label class="layui-form-label">是否设定抵押</label>
        <div class="layui-input-inline">
            <select name="con_house_sfsddy" lay-filter="con_house_sfsddy" value=""  lay-verify="required">
                <option value="">请选择</option>
                <option value="1">是</option>
                <option value="2">否</option>
            </select>
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">供暖方式</label>
        <div class="layui-input-inline">
            <select name="con_house_gnfs" lay-filter="con_house_gnfs" value=""  lay-verify="required">
                <option value="">请选择</option>
                <option value="1">集中暖气</option>
                <option value="2">自采暖</option>
                <option value="3">中央空调</option>
                <option value="4">无暖气</option>
            </select>
        </div>
    </div>


    <div class="layui-form-item">
        <label class="layui-form-label">选择地区</label>
        <div class="layui-input-inline">
            <select name="provid" id="provid" lay-filter="provid" value=""  lay-verify="required">
                <option value="">请选择省</option>
            </select>
        </div>
        <div class="layui-input-inline">
            <select name="cityid" id="cityid" lay-filter="cityid" value=""  lay-verify="required">
                <option value="">请选择市</option>
            </select>
        </div>
        <div class="layui-input-inline">
            <select name="areaid" id="areaid" lay-filter="areaid" value=""  lay-verify="required">
                <option value="">请选择县/区</option>
            </select>
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label"><span style="color: #FF5722">*</span>公寓详细地址</label>
        <div class="layui-input-inline">
            <input type="text" class="layui-input" name="con_house_gyxxdz" lay-verify="required">
        </div>
    </div>



    <div class="layui-form-item">
        <label class="layui-form-label"><span style="color: #FF5722">*</span>产权证明</label>
        <div class="layui-input-inline">
            <button type="button" class="layui-btn layui-btn-sm" id="up">
                <i class="layui-icon">&#xe67c;</i>添加图片
            </button>
            <input type="hidden" name="con_house_cqzm" value="" lay-verify="con_house_cqzm">
            <input type="hidden" name="tch_id" value={$house['tch_id']}>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button id="save" class="layui-btn" lay-submit lay-filter="save">保存</button>
            <button id="upup" style="display:none" class="layui-btn" >保存</button>
        </div>
    </div>
</form>

<script type="text/javascript">
    layui.use(['layer','form','upload'],function(){
        form = layui.form;
        layer = layui.layer;
        $ = layui.jquery;
        upload = layui.upload;
        upload.render({
            elem: '#up'
            ,url: '__PUBLIC__/admin/apartment/upload'
            ,auto: true //选择文件后不自动上传
            ,bindAction: '#upup' //指向一个按钮触发上传
            ,multiple: true
            ,data: {
                id: function(){
                    //console.log($('input[name="name"]').val());
                    return $('input[name="id"]').val();
                }
            }
            ,done: function(res, index, upload){
                //获取当前触发上传的元素，一般用于 elem 绑定 class 的情况，注意：此乃 layui 2.1.0 新增
                var item = this.item;
                // console.log(item);
                // console.log(res);
                // console.log(index);
                // console.log(upload);
                layer.msg(res.msg,{icon:1,time:1100});
                $("#up").after('<img src="'+res.msg+'" alt="" style="width: 200px">');
                $('input[name="con_house_cqzm"]').val($('input[name="con_house_cqzm"]').val()+res.msg+'----');
            }
        });
        form.on('submit(save)', function(data){
            //console.log(data.elem.id); //得到checkbox原始DOM对象
            //console.log(data.elem.checked); //开关是否开启，true或者false
            // console.log(data.value); //开关value值，也可以通过data.elem.value得到
            // console.log(data.othis); //得到美化后的DOM对象
            var name = $.trim($('input[name="provid"]').val());
            var phone = $.trim($('input[name="phone"]').val());
            var id_card = $.trim($('input[name="id_card"]').val());
            var provid = $('select[name="provid"]').val();
            var cityid = $('select[name="cityid"]').val();
            var areaid = $('select[name="areaid"]').val();
            // console.log(data.elem);
            console.log(threeSelectData);

            //.serialize()是将表单中的值序列化id=0&username=2&gid=1&pwd=2&truename=2
            $.post('__PUBLIC__/admin/apartment/save',$('form').serialize()+'&con_house_province=123&con_house_city=123&con_house_area=456',function(res){
                //console.log(res);
                if(res.code>0){
                    layer.alert(res.msg,{icon:2});
                }else{
                    layer.msg(res.msg);
                    // layer.msg('文字保存成功，正在提交图片请稍候。。。', {icon: 16,time: 100000,shade : [0.5 , '#000' , true]});
                    // var d1 = document.getElementById('upup');
                    // d1.click();
                    //setTimeout(function(){parent.window.location.reload();},1000);
                    //setTimeout(function(){window.location.reload();},1000);
                }
            },'json');return false;
        });

        form.val("form", { //formTest 即 class="layui-form" 所在元素属性 lay-filter="" 对应的值'con_house_nature' => string '1' (length=1)
            'con_house_cqzslb':'{$house['con_house_cqzslb']}'
            ,'con_house_nature': '{$house['con_house_nature']}'
            ,'con_house_zsbh': '{$house['con_house_zsbh']}'
            ,'con_house_cqdz': '{$house['con_house_cqdz']}'
            ,'con_house_jzmj': '{$house['con_house_jzmj']}'
            ,'con_house_jssl_s': '{$house['con_house_jssl_s']}'
            ,'con_house_jssl_t': '{$house['con_house_jssl_t']}'
            ,'con_house_jssl_c': '{$house['con_house_jssl_c']}'
            ,'con_house_jssl_w': '{$house['con_house_jssl_w']}'
            ,'con_house_zhrssx': '{$house['con_house_zhrssx']}'
            ,'con_house_sfsddy': '{$house['con_house_sfsddy']}'
            ,'con_house_gnfs': '{$house['con_house_gnfs']}'
            ,'con_house_gyxxdz': '{$house['con_house_gyxxdz']}'
            ,'con_house_cqzm': '{$house['con_house_cqzm']}'
            ,'con_house_province': '{$house['con_house_province']}'
            ,'con_house_city': '{$house['con_house_city']}'
            ,'con_house_area': '{$house['con_house_area']}'
            ,'con_contract_id': '{$house['con_contract_id']}'
            // ,'provid' :  '420000'
            // ,'cityid' :  '420100'
            // ,'areaid' :  '420115'
        });
        form.verify({
            con_house_nature: function(value, item){ //value：表单的值、item：表单的DOM对象
                if(!new RegExp("^[a-zA-Z0-9_\u4e00-\u9fa5\\s·]+$").test(value)){
                    return '用户名不能有特殊字符';
                }
                if(/(^\_)|(\__)|(\_+$)/.test(value)){
                    return '用户名首尾不能出现下划线\'_\'';
                }
                if(/^\d+\d+\d$/.test(value)){
                    return '用户名不能全为数字';
                }
            }
            ,con_house_cqzm:[/^\s*$/,'请上传图片']
            //我们既支持上述函数式的方式，也支持下述数组的形式
            //数组的两个值分别代表：[正则匹配、匹配不符时的提示文字]
            ,pass: [/^[\S]{6,12}$/,'密码必须6到12位，且不能出现空格']

        });
    });


    // window.setInterval("ssave()",10000);//每隔1秒，调用一次getDateDemo()
    // function ssave(){
    //     console.log(navigator);
    // }
</script>
</body>
</html>